package org.example.basic.day03;

/**
 * @author 清倌
 */
public class Demo01多态 {
    public static void main(String[] args) {
        //向上
        show(new Dog());
        show(new Cat());
        Cat cat=(Cat) new Animal();
    }
    public static void show(Animal animal){
        animal.eat();
    }
}

class Animal{
    public void eat(){
        System.out.println("动物吃饭");
    }
}

class Dog extends Animal{

    @Override
    public void eat() {
        System.out.println("狗吃骨头");
    }
}
class Cat extends Animal{
    String name="吃老鼠";
    @Override
    public void eat() {
        System.out.println("猫吃鱼");
    }
}
